package project.euler.honk.problem.to100;

import java.math.BigInteger;

public final class Problem53 {
	
	private static BigInteger getBlaFac(int n, int r) {
		BigInteger result = BigInteger.ONE;
		for(int i = n - r; i > 1; i--) {
			result = result.multiply(BigInteger.valueOf(i));
		}
		return result;
	}

	public static int solve() {
		
		final BigInteger min = BigInteger.valueOf(1000000);
		int count = 0;
		BigInteger nfac = BigInteger.ONE;
		for (int n = 1; n <= 100; n++) {
			nfac = nfac.multiply(BigInteger.valueOf(n));
			BigInteger rfac = BigInteger.ONE;
			for (int r = 1; r <= n; r++) {
				rfac = rfac.multiply(BigInteger.valueOf(r));
				BigInteger blafac = getBlaFac(n, r);
				BigInteger current = nfac.divide(rfac.multiply(blafac));
				if(current.compareTo(min) == 1) {
					count++;
				}
			}
		}
		return count;
	}
	
	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		int count = solve();
		long end = System.currentTimeMillis();
		System.out.println("Result: " + count + " Time: " + (end - start));
	}

}
